package com.etc.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.etc.dao.CompanyMapper;
import com.etc.entity.Company;
import com.etc.entity.LayUiData;
import com.etc.service.CompanyService;

@Service
public class CompanyServiceImpl implements CompanyService {

	@Autowired
	private CompanyMapper companyMapper;
	
	@Override
	public Company getCompany(int comId) {
		// TODO Auto-generated method stub
		return companyMapper.getCompany(comId);
	}
	
	@Override
	public boolean addCompany(Company company) {
		// TODO Auto-generated method stub
		return companyMapper.addCompany(company) > 0;
	}

	@Override
	public boolean delCompany(int comId) {
		// TODO Auto-generated method stub
		return companyMapper.delCompany(comId) > 0;
	}

	@Override
	public boolean updateCompany(Company company) {
		// TODO Auto-generated method stub
		return companyMapper.updateCompany(company) > 0;
	}

	@Override
	public List<Company> getNoCompanyByLike(int page, int limit, String strLike) {
		// TODO Auto-generated method stub
		int start = (page - 1) * limit;
		return companyMapper.getNoCompanyByLike(start, limit, strLike);
	}

	@Override
	public List<Company> getCompanyByLike(int page, int limit, String strLike) {
		// TODO Auto-generated method stub
		int start = (page - 1) * limit;
		return companyMapper.getCompanyByLike(start, limit, strLike);
	}

	@Override
	public int getCompanyCount(int comState) {
		// TODO Auto-generated method stub
		return companyMapper.getCompanyCount(comState);
	}
	
	@Override
	public LayUiData<Company> getNoCompany(int page, int limit, String strLike) {
		// TODO Auto-generated method stub
		int start = (page - 1) * limit;
		LayUiData<Company> laydata = new LayUiData<Company>();
		List<Company> list = companyMapper.getNoCompanyByLike(start, limit, strLike);
		laydata.setCode(0);
		laydata.setMsg("");
		laydata.setCount(companyMapper.getCompanyCount(2));//后续替换成实际的记录数
		laydata.setData(list);
		System.out.println("laydata:" + laydata);
		return laydata;
	}

	@Override
	public LayUiData<Company> getCompany(int page, int limit, String strLike) {
		// TODO Auto-generated method stub
		int start = (page - 1) * limit;
		LayUiData<Company> laydata = new LayUiData<Company>();
		List<Company> list = companyMapper.getCompanyByLike(start, limit, strLike);
		laydata.setCode(0);
		laydata.setMsg("");
		laydata.setCount(companyMapper.getCompanyCount(1));//后续替换成实际的记录数
		laydata.setData(list);
		System.out.println("laydata:" + laydata);
		return laydata;
	}

	@Override
	public List<Company> getCompanyRecommend(int page, int limit, String strLike) {
		// TODO Auto-generated method stub
		int start = (page - 1) * limit;
		return companyMapper.getCompanyRecommend(start, limit, strLike);
	}

	@Override
	public LayUiData<Company> getRecommend(int page, int limit, String strLike) {
		// TODO Auto-generated method stub
		int start = (page - 1) * limit;
		LayUiData<Company> laydata = new LayUiData<Company>();
		laydata.setCode(0);
		laydata.setMsg("");
		laydata.setCount(companyMapper.getRecCount(2));//后续替换成实际的记录数
		laydata.setData(companyMapper.getCompanyRecommend(start, limit, strLike));
		System.out.println("laydata:" + laydata);
		return laydata;
	}

}
